
keep if  ( yearsince>=-4 & yearsince<=6 ) 

capture frame drop results
frame create results str10 outcomevar evicted notevicted time

foreach var of varlist move {

reg `var' evictionorder qdum2-qdum11 evictXq2-evictXq11 i.yearsince i.courtq 
		
*Calculate omitted group baseline mean
sum `var' if evictionorder==0 & yearsince==-4  & e(sample)==1
local basemean=r(mean)
		
* adding period 1 (first) estimates
local rel_q=1-5
local qplot=`rel_q' 
local noevictplot= `basemean'
local evictplot=`basemean'+ _b[evictionorder] 	
frame post results ("`var'")  (`evictplot') (`noevictplot') (`qplot')
	
foreach num of numlist 2(1)11 {
			local rel_q=`num'-5
			local qplot=`rel_q' 
			local noevictplot= `basemean'+_b[qdum`num']
			local evictplot=`basemean'+ _b[evictionorder]+_b[qdum`num']+_b[evictXq`num'] 
			frame post results ("`var'")  (`evictplot') (`noevictplot') (`qplot')
}
		
}
frame change results

gen outcome="Any Move since last year" 

save  ${Inputs}\NY_moves_eventstudy, replace

********************************************************************************

frame change default
capture frame drop results
frame create results str10 outcomevar evicted notevicted time

foreach var of varlist nqual {

reg `var' evictionorder qdum2-qdum11 evictXq2-evictXq11 i.yearsince i.courtq 
		
*Calculate omitted group baseline mean
sum `var' if evictionorder==0 & yearsince==-4  & e(sample)==1
local basemean=r(mean)
		
* adding period 1 (first) estimates
local rel_q=1-5
local qplot=`rel_q' 
local noevictplot= `basemean'
local evictplot=`basemean'+ _b[evictionorder] 		
foreach num of numlist 2(1)11 {
			local rel_q=`num'-5
			local qplot=`rel_q' 
			local noevictplot= `basemean'+_b[qdum`num']
			local evictplot=`basemean'+ _b[evictionorder]+_b[qdum`num']+_b[evictXq`num'] 
			frame post results ("`var'")  (`evictplot') (`noevictplot') (`qplot')
}
		
}

frame change results
save  ${Inputs}\NY_nbhood_eventstudy, replace


